import {loginAPI} from '@/api/user'
export default {
  namespaced: true,
  state: {
    token: ""
  },
  mutations: {
    setUserToken (state, payload) {
      state.token = payload
    },
    clearUserInfo(state) {
      // 清除Token
      state.token = ''
    }
  },
  actions: {
    async loginAction (context,  { username, password }) {
      const res=await loginAPI( { username, password })
      context.commit('setUserToken', res.data.token)
    }
  }
}
